using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Boids2D
{
    class Vector
    {
        double x;

        public double X
        {
            get { return x; }
            set { x = value; }
        }
        double y;

        public double Y
        {
            get { return y; }
            set { y = value; }
        }
        double z;

        public double Z
        {
            get { return z; }
            set { z = value; }
        }

        public Vector()
        {
            x = 0;
            y = 0;
            z = 0;
        }

        public Vector(double xIn, double yIn, double zIn)
        {
            x = xIn;
            y = yIn;
            z = zIn;
        }



        /// <summary>
        /// Vector addition
        /// </summary>
        /// <param name="vectorIn"></param>
        /// <returns></returns>
        public Vector Add(Vector vectorIn)
        {
            Vector tempVec = new Vector();
            tempVec.x = this.x + vectorIn.x;
            tempVec.y = this.y + vectorIn.y;
            tempVec.z = this.z + vectorIn.z;
            return tempVec;
        }

        /// <summary>
        /// Vector Subtraction
        /// </summary>
        /// <param name="vectorIn"></param>
        /// <returns></returns>
        public Vector Subtract(Vector vectorIn)
        {
            Vector tempVec = new Vector();
            tempVec.x = this.x - vectorIn.x;
            tempVec.y = this.y - vectorIn.y;
            tempVec.z = this.z - vectorIn.z;
            return tempVec;
        }


        /// <summary>
        /// Scalar multiplication
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Vector Multiply(double value)
        {
            Vector tempVec = new Vector();
            tempVec.x = this.x * value;
            tempVec.y = this.y * value; ;
            tempVec.z = this.z * value; ;
            return tempVec;
        }

        /// <summary>
        /// The magnitude of the vector
        /// </summary>
        /// <returns></returns>
        public double Magnitude()
        {
            double magnitude = Math.Sqrt(Math.Pow(this.x, 2) + Math.Pow(this.y, 2) + Math.Pow(this.z, 2));
            return magnitude;
        }


    }
}
